package object;

public class Date {

    //属性
    public int year;
    public int month;
    public int day;

    //构造方法
    public Date(){
//        year = 2024;
//        month = 12;
//        day = 2;
         this(2024,12,3);//this 调用其他构造方法来简化代码且必须是第一行
        System.out.println("构造方法");
    }

    public Date(int year,int month,int day){
        this.year = year;
        this.month = month;
        this.day = day;
    }

    //方法
    public void setDay(int year,int month,int day){
        this.year = year;
        this.month = month;
        this.day = day;
    }
    public void printDate(){
        System.out.println(year + "-" + month + "-" + day);
    }

    @Override//注解
    public String toString() {
        return "object.Date{" +
                "year=" + year +
                ", month=" + month +
                ", day=" + day +
                '}';
    }

    public static void main(String[] args) {
        Date date = new Date();
        //打印对象
        System.out.println(date);
    }
}
